package com.cloud.salon.gateway.config;

import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import springfox.documentation.swagger.web.SwaggerResource;
import springfox.documentation.swagger.web.SwaggerResourcesProvider;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description Swagger2资源配置
 * @Author wolf--LZH
 * @CreateDate 2019/5/13 0013 下午 9:31
 */
@Component
@Primary
public class SwaggerResourcesConfig implements SwaggerResourcesProvider {

    @Override
    public List<SwaggerResource> get() {
        List resources = new ArrayList<>();
        resources.add(swaggerResource("验证微服务", "/authority/v2/api-docs", "1.0"));
        resources.add(swaggerResource("业务处理微服务", "/business/v2/api-docs", "1.0"));
        resources.add(swaggerResource("成员管理微服务", "/menber/v2/api-docs", "1.0"));
        return resources;
    }

    private SwaggerResource swaggerResource(String name, String location, String version) {
        SwaggerResource swaggerResource = new SwaggerResource();
        swaggerResource.setName(name);
        swaggerResource.setLocation(location);
        swaggerResource.setSwaggerVersion(version);
        return swaggerResource;
    }
}
